<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 教职工-测评任务
 */
class WorkersTaskModel extends BaseModel
{
    protected $name = 'workers_task';

    /**
     * 关联用户名称
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind(['user_name'=>'name','unit_name']);
    }

    /**
     * 关联用户名称
     * @return BelongsTo
     */
    public function userName(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind(['user_name'=>'name']);
    }

    /**
     * 关联用户名称和角色
     * @return BelongsTo
     */
    public function userNameRoleName(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind(['user_name'=>'name','role_name']);
    }

}